from pyecharts.charts import *
from pyecharts import options as opts
from pyecharts.charts import Bar


def base_bar(x, y1, title, legend, color,rotate):
    bar = (
        Bar(init_opts=opts.InitOpts())
            .add_xaxis(x)
            .add_yaxis(legend, y1, color=color, )

            .set_global_opts(
            title_opts=opts.TitleOpts(title=title, ),

            xaxis_opts=opts.AxisOpts(type_="category", axislabel_opts={"rotate": rotate})

        )
            .set_series_opts(
            label_opts=opts.LabelOpts(is_show=True,color="black"),
            markline_opts=opts.MarkLineOpts(
                data=[
                    # opts.MarkLineItem(type_="min", name="最小值"),
                    # opts.MarkLineItem(type_="max", name="最大值"),
                    opts.MarkLineItem(type_="average", name="平均值"),
                ]
            ),
        )
    )
    return bar
